<?php
/*
	商品入库
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?:'add';
if($_RQ['op']=='add'){
	if($_RQ['postdata']){
		$post=get_postdata();
		$post['depot_id']=$depot_id;
		$data=array_fields(array('num','goodstype','depot_id','remark'),$post);
		$goods_id=intval($post['id']);
		$data['goods_id']=$goods_id;
		if(!$depot_id){
			exi('请先选择仓库！','error');
		}
		if(!$goods_id){
			exi('请先选择商品！','error');
		}
		$this->model('depot')->in_goods($data);
		exi('入库成功~','','/in_log/');
	}
	$return['item']=array('goodstype'=>'0');
	$return['htmls']=array(
		'type'=>'edit',
		'edit'=>array(
			//array('type'=>'select','name'=>'depot_id','title'=>'选择仓库','options'=>'depots'),
			array('type'=>'radio','name'=>'goodstype','title'=>'入库类型','options'=>'goods_types'),
			array('type'=>'choose_up','name'=>'id','show'=>array('goodstype'=>0),'title'=>'入库商品ID','action'=>'jy_weishop/goods.get_goods/many/nomerch=1'),
			array('type'=>'choose_up','name'=>'id','show'=>array('goodstype'=>1),'title'=>'入库原材料ID','action'=>'/goods/choose/type=obj'),
			array('type'=>'string','name'=>'title','title'=>'入库商品名称','read'=>true),
			array('type'=>'image','name'=>'image','title'=>'入库商品图片','read'=>true),
			array('type'=>'string','name'=>'num','title'=>'入库数量'),
			array('type'=>'text','name'=>'remark','title'=>'备注'),
		),
	);
	$return['goods_types']=$this->goods_types;
	$return['depots']=$this->pdo_getall('depot',array('uniacid'=>$_SESSION['uniacid']),array('id','title'),'id');
	exi($return);
}